use egui::Vec2;
use QcUI::component::{Button, TextBox};

use crate::inspector::{ComponentState, InspectorContext, InspectorTrait};

impl InspectorTrait for TextBox {
    fn inspector(&mut self, ctx: &mut InspectorContext, state: &mut ComponentState) {
        egui::CollapsingHeader::new("TextBox")
            .default_open(true)
            .show(ctx.ui, |ui| {
                ui.group(|ui| {
                    ui.set_min_width(ui.available_width() - 5.);
                    egui::Grid::new("TextBox")
                        .num_columns(2)
                        .min_col_width(70.)
                        .spacing(Vec2::new(10., 10.))
                        .show(ui, |ui| {
                            ui.label("文本");
                            if self.multiline {
                                ui.text_edit_multiline(&mut self.text);
                            } else {
                                ui.text_edit_singleline(&mut self.text);
                            }

                            ui.end_row();

                            ui.label("提示文本");
                            ui.text_edit_singleline(&mut self.hint_text);
                            ui.end_row();

                            ui.label("多行文本");
                            ui.checkbox(&mut self.multiline, "");
                            ui.end_row();
                        })
                });
            });
    }
}
